<!--
 * @FilePath: ChildrenSev.vue
 * @Author: jack
 * @Date: 2024-05-14 17:03:57
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2024-06-28 15:27:08
 * Copyright: 2024 xxxTech CO.,LTD. All Rights Reserved.
 * @Descripttion: 
-->
<template>
    <div class="layer-common-box">
        <div class="tips"><span>*</span> 请输入大屏名称</div>
        <div class="row-center-flex row">
            <div style="flex: 1;">
                <el-input clearable placeholder="请输入大屏名称" v-model="props.currentItem.content.title"></el-input>
            </div>
        </div>
        <div class="tips"><span>*</span> 请输入公告内容</div>
        <div class="row-center-flex row">
            <div style="flex: 1;">
                <el-input type="textarea" clearable placeholder="请输入公告内容"
                    v-model="props.currentItem.content.notice"></el-input>
            </div>
        </div>
    </div>
</template>
<script lang="ts" setup>
import { ref, onMounted, watch, nextTick } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { getScreenSettingList, operateScreenSetting, getMaterList } from '../Api/index'
interface PropsType {
    currentItem?: any
    typeId?: string
}
const props = withDefaults(defineProps<PropsType>(), {
    currentItem: {},
    typeId: ''
})
const emit = defineEmits<EmitType>()
interface EmitType {
    (e: 'getConfig'): void
}
const title = ref<string>('')
const notice = ref<string>('')
// 初始化数据 拿到父级所传过来的数据
// const getinfo = async () => {
//     if (props.currentItem.content) {
//         if (props.currentItem.content)
//             title.value = JSON.parse(JSON.stringify(props.currentItem.content.title))
//             notice.value = JSON.parse(JSON.stringify(props.currentItem.content.notice))
//     }
// }
watch(
    () => props.typeId,
    async (newValue, oldValue) => {
        // await getinfo()
    },
    { deep: true, immediate: true, }
)
// 添加数据
const submitFrom = async () => {
    if (!notice.value || !title.value) {
        return ElMessage.error('请输入完整信息!')
    }
    const params = {
        type_id: props.typeId,
        content: {
            title: title.value,
            notice: notice.value,
        }
    }
    const res: any = await operateScreenSetting(params)
    if (res.code !== 1) return ElMessage.error(res.message)
    ElMessage.success(res.message)
    refreshChild()
}
const refreshChild = async () => {
    emit('getConfig')
    setTimeout(async () => {
        // await getinfo()
    }, 500);
}
defineExpose({ submitFrom, refreshChild })
</script>
<style lang="scss" scoped>
.layer-common-box {
    height: calc(100vh - 422px);
    overflow-y: scroll;

    .row-center-flex {
        display: flex;
        align-items: center;
        color: #737A80;
        border-radius: 3px;
        width: 53%;
        min-width: 200px;

        .flex-name {
            color: #737A80;
            margin-right: 15px;
        }

        .iconfont {
            font-size: 20px;
            cursor: pointer;
            color: #B8B8B8;
        }

        // 自定义的无限加编辑框的样式
        .del-btn-box {
            margin: 0 15px;
        }
    }
}
</style>